<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hope2</title>
    <link rel="stylesheet" href="https://lib.baomitu.com/bulma/0.9.1/css/bulma.css">
    <link rel="shortcut icon" href="/favicon.ico">
    <script src="https://lib.baomitu.com/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.hcharts.cn/highstock/highstock.js"></script>
    <script src="https://cdn.hcharts.cn/highcharts/modules/exporting.js"></script>
    <script src="https://cdn.hcharts.cn/plugins/highcharts-zh_CN.js"></script>
    <script src="https://cdn.hcharts.cn/highcharts/modules/drag-panes.js"></script>
    <script type="text/javascript">
        var seriesOptions = [];
        var profitChart;
        var stockOptions = {
            chart: {
                zoomType: null,
                // pinchType: null
            },
            rangeSelector: {
                selected: 4
            },
            yAxis: {
                labels: {
                    formatter: function () {
                        return (this.value > 0 ? ' + ' : '') + this.value + '%';
                    }
                },
                plotLines: [{
                    value: 0,
                    width: 2,
                    color: 'silver'
                }]
            },
            plotOptions: {
                series: {
                    compare: 'percent',
                    showInNavigator: true
                }
            },
            tooltip: {
                pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                valueDecimals: 2,
                followTouchMove: false,
                split: true
            },
            series: seriesOptions
        };
        var link = 'http://www.qianyitian.com/index-compare2?days=';
        link = '/index-compare2?days=';
        $(document).ready(function () {
            post();
        });

        function post() {
            var days = $("#days").val();
            var linkNew = link + days;
            $.getJSON(linkNew, function (data) {
                // As we're loading the data asynchronously, we don't know what order it will arrive. So
                // we keep a counter and create the chart when all the data is loaded.
                createChart(data);
                refreshVisible();
            });
        }

        /**
         * Create the chart when all data is loaded
         * @returns {undefined}
         */
        function createChart(data) {
            stockOptions.series = data;
            profitChart = Highcharts.stockChart('profit-container', stockOptions);
        }


        function refreshVisible() {
            $("input[name='etfCheckBox']").each(function (i, box) {
                checkboxOnclick(box.id, box.checked);
            });
        }

        function checkboxOnclick(checkboxId, selected) {
            $.each(stockOptions.series, function (i, etf) {
                if (etf.code == checkboxId) {
                    profitChart.series[i].setVisible(selected);
                }
            });
        }
    </script>
</head>


<body class="layout-default">
<nav id="navbar" class="bd-navbar navbar has-shadow is-spaced">
    <div class="container">
        <div class="navbar-brand">
            <a class="navbar-item" href="https://qianyitian.com/">
                <img style="height:36px;width:36px;" src="https://img.qianyitian.com/icon/logo.png">  <h4
                    class="title is-3">Hope2</h4>
            </a>
        </div>
    </div>
</nav>

<section class="section">
    <div class="container">
        <div class="columns">
            <div class="column is-3">
                <div class="field">
                    <label class="label">计算最近多少天的数据</label>
                    <div class="control">
                        <input id="days" class="input" type="text" name="days" value="40">
                    </div>
                </div>
                <div class="field is-grouped">
                    <div class="control">
                        <button class="button is-link" onclick="post()">Submit</button>
                    </div>
                </div>
            </div>
            <div class="column is-1">
            </div>
            <div class="column is-2">
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000006" name="etfCheckBox" type="checkbox" checked=“checked”
                                       onclick="checkboxOnclick('sh000006',this.checked)">
                                地产指数
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000092" name="etfCheckBox" type="checkbox" checked=“checked”
                                       onclick="checkboxOnclick('sh000092',this.checked)">
                                资源50
                            </label>
                        </div>
                    </div>
                </div>

                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000813" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000813',this.checked)">
                                细分化工
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000820" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000820',this.checked)">
                                煤炭指数
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000827" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000827',this.checked)">
                                中证环保
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000928" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000928',this.checked)">
                                中证能源
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000932" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000932',this.checked)">
                                中证消费
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000933" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000933',this.checked)">
                                中证医药
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sh000935" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sh000935',this.checked)">
                                中证信息
                            </label>
                        </div>
                    </div>
                </div>
            </div>

            <div class="column is-2">
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399136" name="etfCheckBox" type="checkbox" checked=“checked”
                                       onclick="checkboxOnclick('sz399136',this.checked)">
                                电子指数
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399235" name="etfCheckBox" type="checkbox" checked=“checked”
                                       onclick="checkboxOnclick('sz399235',this.checked)">
                                建筑指数
                            </label>
                        </div>
                    </div>
                </div>

                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399237" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399237',this.checked)">
                                运输指数
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399389" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399389',this.checked)">
                                国证通信
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399395" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399395',this.checked)">
                                国证有色
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399417" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399417',this.checked)">
                                新能源车
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399432" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399432',this.checked)">
                                国证汽车
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399437" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399437',this.checked)">
                                国证证券
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399438" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399438',this.checked)">
                                国证电力
                            </label>
                        </div>
                    </div>
                </div>
            </div>

            <div class="column is-2">
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399440" name="etfCheckBox" type="checkbox" checked=“checked”
                                       onclick="checkboxOnclick('sz399440',this.checked)">
                                国证钢铁
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399608" name="etfCheckBox" type="checkbox" checked=“checked”
                                       onclick="checkboxOnclick('sz399608',this.checked)">
                                科技100
                            </label>
                        </div>
                    </div>
                </div>

                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399809" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399809',this.checked)">
                                保险主题
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399967" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399967',this.checked)">
                                中证军工
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399971" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399971',this.checked)">
                                中证传媒
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399986" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399986',this.checked)">
                                中证银行
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399989" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399989',this.checked)">
                                中证医疗
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input id="sz399997" name="etfCheckBox" type="checkbox"
                                       onclick="checkboxOnclick('sz399997',this.checked)">
                                中证白酒
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<hr>
<section class="section">
    <div class="container">
        <div id="container"></div>
    </div>
</section>

<section class="section">
    <div class="container">
        <div id="profit-container" style="min-width:600px;height:1000px"></div>
    </div>
</section>

<hr>
</body>
</html>
